package com.power200.showcase.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.power200.showcase.R;

public class WechatActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wechat);

        RadioGroup radioGroup = (RadioGroup) findViewById(R.id.weRadioGroup);
        final RadioButton weRb1 = (RadioButton) findViewById(R.id.weRb1);
        final RadioButton weRb2 = (RadioButton) findViewById(R.id.weRb2);
        final RadioButton weRb3 = (RadioButton) findViewById(R.id.weRb3);
        final RadioButton weRb4 = (RadioButton) findViewById(R.id.weRb4);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.weRb1:
                        weRb1.setBackgroundResource(R.drawable.we5);
                        weRb2.setBackgroundResource(R.drawable.we2);
                        weRb3.setBackgroundResource(R.drawable.we3);
                        weRb4.setBackgroundResource(R.drawable.we4);
                        break;
                    case R.id.weRb2:
                        weRb1.setBackgroundResource(R.drawable.we1);
                        weRb2.setBackgroundResource(R.drawable.we6);
                        weRb3.setBackgroundResource(R.drawable.we3);
                        weRb4.setBackgroundResource(R.drawable.we4);
                        break;
                    case R.id.weRb3:
                        weRb1.setBackgroundResource(R.drawable.we1);
                        weRb2.setBackgroundResource(R.drawable.we2);
                        weRb3.setBackgroundResource(R.drawable.we7);
                        weRb4.setBackgroundResource(R.drawable.we4);
                        break;
                    case R.id.weRb4:
                        weRb1.setBackgroundResource(R.drawable.we1);
                        weRb2.setBackgroundResource(R.drawable.we2);
                        weRb3.setBackgroundResource(R.drawable.we3);
                        weRb4.setBackgroundResource(R.drawable.we8);
                        break;
                    default:
                        break;
                }
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_wechat, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
